/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package logica;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.mail.Message;

/**
 *
 * @author Leandro
 */
public class ControladorPrincipal {

    private String servidor;
    private int port;
    private String usr;
    private String pass;
    private long frecuenciaVerif;
    private ExpertoMail expertoMail;
    private boolean stop=false;
    private ExpertoPrincipal hilo;

    public ExpertoMail getExpertoMail() {
        return expertoMail;
    }

    public void setExpertoMail(ExpertoMail expertoMail) {
        this.expertoMail = expertoMail;
    }

    public long getFrecuenciaVerif() {
        return frecuenciaVerif;
    }

    public void setFrecuenciaVerif(long frecuenciaVerif) {
        this.frecuenciaVerif = frecuenciaVerif;
    }

    public ExpertoPrincipal getHilo() {
        return hilo;
    }

    public void setHilo(ExpertoPrincipal hilo) {
        this.hilo = hilo;
    }

    public boolean isStop() {
        return stop;
    }

    public void setStop(boolean stop) {
        this.stop = stop;
    }


    

    public void setFrecuenciaVerif(int frecuenciaVerif) {
        this.frecuenciaVerif = frecuenciaVerif;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getServidor() {
        return servidor;
    }

    public void setServidor(String servidor) {
        this.servidor = servidor;
    }

    public String getUsr() {
        return usr;
    }

    public void setUsr(String usr) {
        this.usr = usr;
    }

    public void connect(String server, String usr, String pass, long fverif,int port) {
        this.servidor=server;
        this.port=port;
        this.usr=usr;
        this.pass=pass;
        this.frecuenciaVerif=fverif;
        if(expertoMail==null){
            expertoMail=new ExpertoMail();
        }
        expertoMail.configurate(false, false, port);
        hilo=new ExpertoPrincipal();
        hilo.setUsr(this.usr);
        hilo.setPass(this.pass);
        hilo.setFverif(this.frecuenciaVerif);
        hilo.setPuerto(this.port);
        hilo.setExp(expertoMail);
        hilo.setServer(this.servidor);
        hilo.start();
    }

    public void stop() {
       if(hilo!=null){
            hilo.stop();
            ExpertoXml.finalizarDocumento();
       }
    }



}
